#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "counters.h"
#include "local_history_table.h"
#include "shift_registers.h"
#include "debugger.h"

using namespace std;

void print_branch_record(const branch_record_c* br)
{
    printf("PC: %p\t",br->instruction_addr);
    printf("Target: %p\t",br->instruction_next_addr);
    printf("Taken: %s\t",TF(br->is_taken));
    printf("is_indirect: %s\t",TF(br->is_indirect));
    printf("Conditional: %s\t",TF(br->is_conditional));
    printf("Call: %s\t",TF(br->is_call));
    printf("Return: %s\n",TF(br->is_return));	
}

int main (int argc, const char * argv[])
{   
    if (2 != argc) {
        printf("usage: %s <result file, e.g. res.txt>\n", argv[0]);
        exit(EXIT_FAILURE);
    }

	branch_record_c br; 
    ifstream file(argv[1]);
    initialize_reader(file);

    while (file.eof() == false) {
        read_prediction(file, &br);
        print_branch_record(&br);
    }

    return 0;
}
